package cate.game.play.buff.h;

import cate.common.util.XT;
import cate.game.play.buff.Buff;
import cate.game.play.buff.BuffHandler;
import cate.game.play.config.PlayCfgArgs;
import cate.game.play.fighter.Fighter;
import cate.game.play.proce.action.ctx.ActionCtx;
import easy.java.struct.ref.DoubleRef;

/**
 * 有30%概率免疫本次分摊伤害，每人每回合至多1次；
 */
public class 霓裳BH extends BuffHandler {

	private String buff标签;

	private int 概率;

	private int 回合次数;

	//buff标签=福祸与共&概率=3000&回合次数=1
	@Override
	public void parse(String code) {
		PlayCfgArgs args = new PlayCfgArgs(code);
		buff标签 = args.get("福祸与共");
		概率 = args.getInt("概率", 0);
		回合次数 = args.getInt("回合次数",0);
	}

	private int roundNum;

	@Override
	public void onRoundBegin(ActionCtx action) {
		roundNum = 0;
	}

	@Override
	public void adjustShareDamage(ActionCtx action, Fighter actor, Buff buff, DoubleRef doubleRef) {
		if (!buff.cfg.containTag(buff标签)) {
			return;
		}
		if (roundNum >= 回合次数) {
			return;
		}
		if (!XT.chance(概率)) {
			return;
		}
		doubleRef.v = 0;
		roundNum++;
	}
}
